- 
                Notifications
    
You must be signed in to change notification settings  - Fork 47
 
Create schema submodule #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
21a575e    to
    b05721a      
    Compare
  
            
          
                pkg/cdi/cache_test.go
              
                Outdated
          
        
      | func TestRefreshCache(t *testing.T) { | ||
| if runtime.GOOS == "darwin" { | ||
| t.Skip("skipping on darwin") | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why we're skipping this test on Darwin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look into it too deeply, but my assumption was that the ordering is different there causing the refreshed state to not be the same as encoded in the tests.
I can update the message to make this clearer if you prefer. (to be clear this is actually part of #249)
b05721a    to
    f37288d      
    Compare
  
    | 
           @elezar schema unit tests fail to build it seems:  | 
    
f37288d    to
    8070930      
    Compare
  
    | 
           Thanks @bart0sh. I wrongly assumed that the   | 
    
| 
           @elezar There is something wrong with the package dependencies, I guess.   | 
    
| 
           why schema_test.go uses its own package   | 
    
        
          
                Makefile
              
                Outdated
          
        
      | $(Q)for mod in $$(find . -name go.mod); do \ | ||
| echo "Testing $$(dirname $$mod)..."; ( \ | ||
| cd $$(dirname $$mod) && $(GO_TEST) ./... \ | ||
| ) || exit 1; \ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it exit on the first test failure? If so, could it be modified to run all tests even if one fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this to run all tests and exit on failures afterwards.
          
 I didn't change the test package as part of this change. Maybe the original intent was to test against public interfaces. @klihub do you recall if there was a reason for this?  | 
    
A few thinks I missed need to be cleared.
8070930    to
    f1f5c60      
    Compare
  
    
          
 Go list lists packages in the current module. When you're in the root folder the packages that you list above are the only packages. We already have a number of submodules: where   | 
    
f1f5c60    to
    991563e      
    Compare
  
    
          
 Yes, we do blackbox testing using the public interfaces only. It's normal go practice to put the tests in ${package}_test in that case.  | 
    
          
 Is this package somehow different from others in this project? $ find . -name *_test.go |xargs grep package  | 
    
          
 I think many of the tests in pkg/cdi make minimal use of some unexported functions (for instance newCache, newSpec, validation functions, those sort of things) and that's why they were made part of the package they test. The schema package is mostly a pile of boilerplate with the specific purpose to hide and isolate the xeipuuv/gojsonschema interfaces, transforming them to something behind which we could plug in another implementation without changes to the rest of the code if/once we found one more adequate package. So there it was an obvious choice to go for blackbox testing.  | 
    
| 
           @klihub Thank you for the explanation! Now that makes sense to me.   | 
    
          
 Sure, but that is out of scope for this PR. I'm happy to address that as a follow-up.  | 
    
Signed-off-by: Evan Lezar <[email protected]>
This creates a schema submodule to remove dependencies from the cdi package that is more commonly used. Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
991563e    to
    af0ba04      
    Compare
  
    | 
           /lgtm  | 
    
The github.com/xeipuuv/gojsonschema that is imported for schema validation can be problematic.
This change creates a go submodule at
schemato remove this dependency from the main module.Note that this also moves from a function-based schema validation to using an interface so that the schema-based validators are pluggable into the producer as implemented in #233